/*
* 登录功能
*
* */
function login() {
    var param = {
        phoneNum : $("#username").val(),
        password : md5($("#password").val())
    }
    $.post(config.baseUrl + "/user/login.json",param,function (result) {
        if (result.status == 200) {
            config.saveUser(JSON.stringify(result.data));
            window.location.href = "personCenter-temp.html";
        } else {
            alert(result.msg);
        }


    },"json");
    return false;
}

/*
* 获取验证码
* */
function getSMSCode() {
    var url = config.baseUrl;
    var param = {
        phoneNum : $("#phoneNum").val(),
    }
    $.ajax({
        type:"get",
        url:url + "user/getCode.json",
        data:param,
        dataType:"json",
        success:function (data) {
            alert(data.msg)
        }
    })
}

/*
* 忘记密码
* */
function forgetPassword() {
    var url = config.baseUrl;
    var param = {
        phoneNum : "",
        code : "",
        newPassword : ""
    }
    $.ajax({
        type:"post",
        url:url + "user/forgetPassword.json",
        data:param,
        dataType:"json",
        success:function (data) {

        }
    })
    return false;
}

/*
* 修改登录密码
* */
function modifyPassword() {
    var url = config.baseUrl;
debugger
    var newPassword = $("#newPassword").val();
    var newPassword1 = $("#newPassword1").val();
    var param = {
        userId : config.getUserId(),
        oldPassword :$("#oldPassword").val(),
        newPassword : newPassword
    }
    if(newPassword != newPassword1){
        alert("新密码和确认密码不一致！");
        return false;
    }
    $.ajax({
        type:"post",
        url:url + "user/modifyPassword.json",
        data:param,
        dataType:"json",
        success:function (data) {
            alert(data.msg);
        }
    })
    return false;
}

/*
* 修改支付密码
* */
function modifyAccountPassword() {
    var url = config.baseUrl;

    var newPayPassword = $("#newPayPassword").val();
    var newPayPassword1 = $("#newPayPassword1").val();
    var param = {
        userId :config.getUserId(),
        oldPayPassword :$("#oldPayPassword").val(),
        newPayPassword : $("#newPayPassword").val()
    }
    if(newPayPassword != newPayPassword1){
        alert("新密码和确认密码不一致！");
        return false;
    }
    $.ajax({
        type:"post",
        url:url + "user/modifyAccountPassword.json",
        data:param,
        dataType:"json",
        success:function (data) {
            alert(data.msg)
        }
    })
    return false;
}

/*
* 忘记支付密码
* */
function forgetAccountPassword() {
    var url = config.baseUrl;

    var newPayPassword = $("#newPayPassword").val();
    var newPayPassword1 = $("#newPayPassword1").val();
    var param = {
        phoneNum : $("#phoneNum").val(),
        code :$("#code").val(),
        newPayPassword : newPayPassword
    }
    if(newPayPassword!=newPayPassword1){
        alert("新密码和确认密码不一致！");
        return false;
    }
    $.ajax({
        type:"post",
        url:url + "user/forgetAccountPassword.json",
        data:param,
        dataType:"json",
        success:function (data) {
            if(data.status == '200'){
                alert(data.msg);
            }else{
                alert(data.msg)
            }
        }
    })
    return false;
}